﻿#region Usings

using System.Collections.ObjectModel;
using System.Linq;
using KanbanBoard.Client.Model.Query;

#endregion

namespace KanbanBoard.Client.ViewModel.TaskBoardUseCase {
    public class ColumnRepository : ObservableCollection<ColumnViewModel> {
        private readonly IContext context;

        public ColumnRepository(IContext context) {
            this.context = context;
        }

        public void Bind(TaskBoard taskBoard) {
            Clear();
            taskBoard.Columns.Select(Translate)
                .ToList()
                .ForEach(Add);
        }

        private ColumnViewModel Translate(Column column) {
            return new ColumnViewModel(column, context);
        }
    }
}